package com.dmooo.yxmmerchant.view.model;

import android.content.Context;

import com.common.net.entity.SubjectPost;
import com.common.net.listener.HttpOnNextListener;
import com.common.net.subscribers.ProgressSubscriber;
import com.dmooo.yxmmerchant.http.HttpManager;
import com.dmooo.yxmmerchant.view.contract.NewsContract;

import java.util.HashMap;
import java.util.Map;

public class NewsModel implements NewsContract.NewsMdl {
    private Context context;
    public NewsModel(Context context) {
        this.context=context;
    }

    @Override
    public void getNewDetail(String article_id, HttpOnNextListener listener) {
        Map<String, Object> map = new HashMap<>();
        map.put("article_id", article_id);
        SubjectPost subjectPost = new SubjectPost(new ProgressSubscriber(listener, context, true, false, "加载中..."), map);
        HttpManager.getInstance().getArticleMsg(subjectPost);
    }

    @Override
    public void getListByCatId(String cat_id, int page, HttpOnNextListener listener) {
        Map<String, Object> map = new HashMap<>();
        map.put("cat_id", cat_id);
        map.put("p", page);
        map.put("per", 10);
        SubjectPost subjectPost = new SubjectPost(new ProgressSubscriber(listener, context, false, false, "加载中..."), map);
        HttpManager.getInstance().getArticleListByCatId(subjectPost);
    }
}
